-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit testing, renaming functions, adding docs #124
Conversation
Just a small query: |
Good question. It is because these are the names of the two plots 'table_fig' and 'empty_fig' in the code. 'table_fig' is the html output that returns the table, and 'empty_fig' is the bar chart that counts how many variables have empty descriptions. I am not sure how to suppress this console output whilst also allowing the figures to be returned in the 'Viewer' tab but there is likely a way, if we wanted to do that. Also, if 'empty_fig' is a confusing name we could call it 'barplot_fig' instead. Perhaps this is even clearer: |
browseMetadata()
as per your suggestion, and it works now! |
Question - running: When changing demo file: |
The arguments in the documentation is also a bit unclear - i.e. under Arguments for |
Ah, I see the confusion. It should be: The 'system.file' syntax is only used for package data. Let me see if it would be simple to change the code so that you don't have to give any inputs when running browseMetadata in demo mode (as like mapMetadata).
Nice catch! This is an error. I copied this over from mapMetadata SolutionPlease see my commit 'make demo run simpler' which should have solved this. You may want to re-installed the package again |
Yes this would be great! if it's a default then it would be great to have that as the default parameter so you don't have to specify it :) |
Thanks for fixing :) Pulled changes and reinstalled - I'm going to try rerun now |
It's worked :-) great! |
Maybe this is being picky, but in terms of storage it may be nicer to have the BROWSE_datasetX_V.csv in a more normalised format, i.e. trying to remove duplicate rows if possible. So instead of
Having something like this:
Means there's less data to store/less rows but it's got the same info :) Not necessary though, so please ignore if it's a bit long to implement! |
Continued testing browseMetadata
|
Testing mapMetadata.R
outputs look good, then deleted
and can see that only those matched from lookup are autocategorised:
|
Lastly, testing
prints output: looks good! Minor points:
|
@Rainiefantasy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving this PR! 😸
Closes #38
Overall description
This PR adds unit testing for this R package.
In order to do this, the main package function(s) needed to be split up into smaller functions, in order to test. When writing tests, it was sometimes obvious that functions should be improved in various ways, and a few sub-optimal coding things were found and corrected.
It also became obvious that there were 2 parts to this package as a whole - the browsing and the mapping. This has been made clearer now, by splitting up two functions, and adding some nice plots.
Changes implemented (by directory)
Parent directory:
.Rbuildignore
and.gitignore
files to better reflect the package structureDESCRIPTION
andNAMESPACE
reflect changes to the package, specifically to do with how imports and exports are handledREADME.md
reflects the new code changesR
directory:There are now 4 main functions that a user can interact with:
browseMetadata.R
(new!)mapMetadata.R
(previously domain_mapping.R)mapMetadata_compare_outputs.R
(previously compare_sessions.R)mapMetadata_convert_outputs.R
(previously convert_outputs.R)All of the other files in the
R
directory are either:data
directory:The same 2 dataframes were made multiple times across the functions. Therefore, to reduce lines of code, they have now been included in the package data:
data/log_Output.rda
data/Output.rda
These can now be read into the functions with one line e.g.
Output <- get("Output")
inst
directory:Some example inputs and outputs have been moved or added, so they can be referenced in the README, or other documentation throughout the package.
man
directory:All new functions require documentation via
.Rd
filestests
directory:All functions require unit tests, written with the testthat package.
Checklist to make it ready for review (for @RayStick):
Checklist for reviewers (@Rainiefantasy )
Tips for user testing (@Rainiefantasy)
setwd('your-path/test_dir')
remove.packages("browseMetadata")
- you may need to specify a pathdevtools::install_github("aim-rsf/browseMetadata", ref = 'big-refactor')
library(browseMetadata)
Testing
browseMetadata.R
Testing
mapMetadata.R
Testing
mapMetadata_convert_outputs.R
mapMetadata_convert_outputs(output_csv = 'OUTPUT_xxx.csv', output_dir = /path/test_dir/')
Check that the above call outputs L-OUTPUT_xxx.csv and that any rows that had multiple categorizations have now been split onto their own rows.
Testing
mapMetadata_compare_outputs.R
inst/inputs
folder to point towards as quick inputs for some of the arguments